<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body,
        html {
            background-color: rgba(0, 0, 0, 0);
        }

        .box-white {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            background-color: #fff;
            border-radius: 20px 20px 0 0;
            overflow: hidden;
            padding: 0 30px;
        }

        .caption {
            position: relative;
            font-size: 16px;
            font-weight: 500;
            color: #333333;
            text-align: center;
            line-height: 16px;
            margin-top: 30px;
        }

        .icon-close {
            position: absolute;
            right: 0;
            top: 0;
            width: 16px;
            height: 16px;
        }

        .tips {
            margin-top: 20px;
            font-size: 13px;
            font-weight: 400;
            color: #BFBFBF;
            line-height: 18px;
        }

        .activa-type {
            padding: 10px 15px;
            margin-top: 15px;
            background: #F8F8F8;
            border-radius: 5px;
        }

        .icon-type {
            width: 54px;
            min-width: 54px;
            height: 54px;
            margin-right: 10px;
        }

        .activa-type .title {
            font-size: 16px;
            font-weight: 400;
            color: #333333;
            line-height: 18px;
        }

        .activa-type .des {
            font-size: 12px;
            font-weight: 400;
            color: #BFBFBF;
            line-height: 18px;
            margin-top: 4px;
        }

        .btn-activation {
            height: 40px;
            background: #FD9B43;
            border-radius: 20px;
            font-size: 15px;
            font-weight: 500;
            color: #FFFFFF;
            margin: 10px 0;
        }

        .btn-disbale {
            height: 40px;
            background: rgba(253, 155, 67, 0.3);
            border-radius: 20px;
            font-size: 15px;
            font-weight: 500;
            color: #FFFFFF;
            margin: 10px 0;
        }
    </style>
</head>

<body>
    <div class="vueApp" v-cloak>
        <div class="box-white">
            <div class="caption">选择激活方式
                <img src="../../image/ui/close.png" onclick="api.closeFrame()" alt="" class="icon-close">
            </div>
            <div class="tips">注：绘本自激活起一年内有效</div>
            <div class="activa-type" data-flex="cross:center" onclick="openEnterFrm()">
                <img src="../../image/ui/activa-hb.png" alt="" class="icon-type">
                <div data-flex-box="1">
                    <div class="title">激活码</div>
                    <div class="des">请输入实物绘本所赠送的激活码</div>
                </div>
            </div>
            <div class="activa-type" data-flex="cross:center" onclick="openScanner()">
                <img src="../../image/ui/qrcode_hb.png" alt="" class="icon-type">
                <div data-flex-box="1">
                    <div class="title">扫描二维码</div>
                    <div class="des">扫描实物绘本背部二维码激活当前绘本</div>
                </div>
            </div>
            <div class="tips" data-flex="main:center">没有激活码?</div>
            <div :class="pmsProductId ? 'btn-activation' : 'btn-disbale'" data-flex="cross:center main:center"
                onclick="toMall()">马上获取激活码</div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm, pageParam;
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        pageParam = api.pageParam;
        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                pmsProductId: pageParam.pmsProductId
            }
        });
    }

    // 点击激活码
    function openEnterFrm() {
        fnOpenFrame({
            name: 'enter_frm',
            url: './enter_frm.html',
            rect: {
                x: 0, y: 0, w: 'auto', h: 'auto'
            },
            bgColor: 'rgba(0,0,0,0.5)',
            pageParam: {
                title: '激活码',
                placeholder: '请输入激活码',
                winName: pageParam.winName,
                frameName: pageParam.frameName
            }
        });
        fnDelayCloseFrame();
    }

    // 点击扫描二维码
    function openScanner() {
        api.execScript({
            name: pageParam.winName,
            frameName: pageParam.frameName,
            script: "fnOpenScanner(1)"
        });
        fnDelayCloseFrame();
    }

    // 跳转到商城
    function toMall() {
        if (vm.pmsProductId) {
            fnBannerOpenShop({
                type: 2,
                id: vm.pmsProductId
            });
            fnDelayCloseFrame();
            api.execScript({
                name: pageParam.winName,
                frameName: pageParam.frameName,
                script: "fnDelayCloseWin()"
            });
        }
    }

    // params
    // type 1 分类 2 商品 3 基本营销 4 满赠营销
    // id 业务ID
    // name 业务名字
    function fnBannerOpenShop(params) {

        const url = "https://shop98220230.m.youzan.com/wscshop/showcase/feature?alias=QPOMQr3MUm&kdt_id=98028062";
        api.openApp({
            iosUrl: url,
            uri: url,
        });

        // 到商城
        // fnOpenWin({
        //     name: 'shop_mall_win',
        //     url: '../tabs/tab_shop.html',
        //     slidBackEnabled: false,
        //     reload: false,
        //     animation: {
        //         type: 'movein',
        //         subType: 'from_bottom',
        //         duration: 500
        //     },
        //     pageParam: {
        //         bannerParams: params
        //     }
        // });
        // api.sendEvent({
        //     name: 'fnBannerOpenShop',
        //     extra: {
        //         bannerParams: params
        //     }
        // });
    }
</script>

</html>